package com.ruoyi.hr.service.impl.salary;


import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.hr.domain.Authority;
import com.ruoyi.hr.mapper.EmpSalaryCalculationMapper;
import com.ruoyi.hr.mapper.salary.SpecialPersonSalaryQueryMapper;
import com.ruoyi.hr.service.salary.SpecialPersonSalaryQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class SpecialPersonSalaryQueryServiceImpl implements SpecialPersonSalaryQueryService {

    @Autowired
    SpecialPersonSalaryQueryMapper specialPersonSalaryQueryMapper;

    @Autowired
    private EmpSalaryCalculationMapper empSalaryCalculationMapper;

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> findData(List<Authority> authorities, Map map, int isAdmin) {
        //拼接动态SQL
        List<String> ProList = empSalaryCalculationMapper.findObjTypeAll(map.get("pgid").toString());
        for (int i = 0; i < ProList.size(); i++) {
            ProList.set(i, ProList.get(i).replace("（", "("));
            ProList.set(i, ProList.get(i).replace("）", ")"));
        }
        map.put("pro", ProList);
        return specialPersonSalaryQueryMapper.findData(authorities,map,isAdmin);
    }
}
